<?php
namespace app\http\controller;
use think\worker\Server;
use workerman\lib\Timer;
use app\index\controller\Index;
class Worker extends Server
{
	protected $socket = 'http://0.0.0.0:2346';
	public function onMessage($connection,$data)
	{
		$connection->send(json_encode($data));
	}
    public function onWorkerStart($work)
    {
        $this->task();
    }
    public function task()
    {
        $data = new Index();
        $time = 2;
        Timer::add($time,function () use ($data) {
            $data->getapi();
        });
    }
}